#include "MyApplicationManager.h"

#include <windows.h>
#include <GL/gl.h>

#define _USE_MATH_DEFINES
#include <cmath>
#define TO_RADIANS_FACTOR (M_PI / 180.0)
#define TO_DEGREES_FACTOR (180.0 / M_PI)

#include <LDFToolkit/VisComponentGL.h>
#include <LDFToolkit/Utils/TextureManager.h>
#include <LDFToolkit/Strategies/Drawers/GradientBorderStrategy.h>


#include <iostream>
#include <string>

#include "BackgroundImageStrategy.h"


MyApplicationManager::MyApplicationManager(FrameTimer* timer) : DefaultManager(timer)
{	
	backGroundComponent = new VisComponentGL();
	BackgroundImageStrategy * backStrategy = new BackgroundImageStrategy("images/0011.png");
	backGroundComponent->pushStrategy(backStrategy);

	initialize();
}

MyApplicationManager::~MyApplicationManager(void)
{
	delete backGroundComponent;
}

void MyApplicationManager::resize(unsigned int width, unsigned int height)
{
	DefaultManager::resize(width, height);	

	backGroundComponent->setPosition(width/2.0, height/2.0);
	backGroundComponent->setWidth(width);
	backGroundComponent->setHeight(height);
}


void MyApplicationManager::initComponents()
{
	float borderColor[4] = { 0.3, 0.5, 1.0, 1.0 };
	float selectedColor[4] = { 0.8, 0.6, 0.1, 1.0 };

	rootComponent = new VisComponentGL();
	rootComponent->setPosition(Point3f(400, 300, 0));
	rootComponent->setWidth(800);
	rootComponent->setHeight(600);
	GradientBorderStrategy* rootBorder = new GradientBorderStrategy();
	rootBorder->setBorderWidth(-10.0);
	rootBorder->setColor(borderColor);
	rootComponent->pushStrategy(rootBorder);
	FrictionSurfaceStrategy* friction = new FrictionSurfaceStrategy();
	friction->setBorderWidth(50);
	friction->setBorderHeight(50);
	rootComponent->pushStrategy(friction);
	rootComponent->getStrategy()->initPropertiesComponent();


	//adding the background image
	addComponent(backGroundComponent);
}
